package 抽象数据类型;

import java.util.Scanner;



public class TestQueue {
    public static void main(String[] args) {
	Queue<String> stack = new Queue<>();
	Scanner scanner =new Scanner(System.in);
	String string = scanner.nextLine();
	String[] arr = string.split(" ");
	
	for(String item:arr) {
	   System.out.println(item); 
	    if(!item.equals("-")) {
		stack.enqueue(item);
	    }
	    else if (!stack.isEmpty()) {
			System.out.println(stack.dequeue() + " ");

	    }
	}
	

    }
}
	 